#ifndef WIDGET_H
#define WIDGET_H

#include "common/baseeditor.h"
#include "commander.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public BaseEditor
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

    void generateMenu();
    void updateView();
    void startCommander();
    void stopCommander();
    void onError();
    void onStartSuccess();
    void onReadyRead(const QString &reply);
    void query(const QString &kw);

signals:
    void execute(const QString &command,const QString &program="cmd");

protected:
    void keyPressEvent(QKeyEvent *event);

private slots:
    void on_btn_paste_clicked();
    void on_btn_clean_clicked();
    void on_kw_returnPressed();
    void on_listView_doubleClicked(const QModelIndex &index);

    void on_cmd_returnPressed();

private:
    Ui::Widget *ui;

    QStringListModel *listModel;
    Commander *commander;
    QThread workerThread;
};
#endif // WIDGET_H
